#include <iostream>
#include <time.h>

using namespace std;

#include "AVLTree.h"
#include "RBTree.h"

void testAVLTree()
{
	//int arr1[] = { 8, 6, 12, 7, 13, 15, 3, 10, 20, 5, 2 };
	int arr1[] = { 8, 6, 12, 3, 7, 10, 15, 2, 5, 13, 20 };
	int arr2[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
	int arr3[] = { 10, 8, 15, 7, 9, 5 };
	AVLTree<int> avlt;
	for (auto e : arr1)
	{
		avlt.Insert(e);
	}
	avlt.InOrder();
	cout << avlt.IsAVLTree() << endl;
	//bool isBalance = avlt.IsAVLTree();
}
void testAVLTree2()
{
	srand(time(0));
	const size_t N = 100000;
	AVLTree<int> t;
	for (size_t i = 0; i < N; ++i)
	{
		size_t x = rand();
		t.Insert(x);
	}

	t.InOrder();

	cout << t.IsAVLTree() << endl;
}
void testRBTree()
{
	RBTree<int> rbt;
	int arr1[] = { 8, 6, 12, 3, 7, 10, 15, 2, 5, 13, 20 };
	for (auto e : arr1)
	{
		rbt.Insert(e);
	}
	rbt.InOrder();
	cout << rbt.IsValidRBTRee() << endl;
}
void testRBTree2()
{
	RBTree<int> t;
	const size_t N = 1000;
	for (size_t i = 0; i < N; ++i)
	{
		size_t x = rand();
		t.Insert(x);
	}

	t.InOrder();

	cout << t.IsValidRBTRee() << endl;
}
int main()
{
	//testAVLTree();
	testRBTree2();

	return 0;
}

